$ErrorActionPreference = "Stop"
$directory="C:\hr\dir"
for($i=1; $i -le 10; $i++)
{
    $dirname=$directory+$i 
    try {
            
        New-Item  -ItemType Directory -Path "$dirname"
        $message="Directory $dirname is created successfully"
        write-eventlog -LogName aplct1 -Source "localcomputer2" -EventId 1000 -EntryType Information -Message $message
    }
    catch {
        write-eventlog -LogName aplct1 -Source "localcomputer2" -EventId 1001 -EntryType Error -Message $_.Exception.Message 
    }

}